package com.koron.device.service;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.device.bean.Equipment;
import com.koron.device.bean.EquipmentExcel;
import com.koron.device.bean.EquipmentParams;
import com.koron.device.bean.EquipmentQuery;
import com.koron.device.bean.dto.LineEquipmentVo;
import com.koron.device.bean.po.EquipmentPo;
import com.koron.device.bean.query.AdvancedQuery;
import com.koron.device.bean.query.ERcodeQuery;
import com.koron.device.bean.query.EqParamQuery;
import org.apache.poi.ss.usermodel.Workbook;
import org.koron.ebs.mybatis.SessionFactory;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * @author qingfeng
 * @description: TODO
 * @date 2021/7/7 17:27
 */
public interface EquipmentService {

    Response insert(SessionFactory factory, Equipment equipment);

    Response update(SessionFactory factory, Equipment equipment);

    Response delete(SessionFactory factory, String id);

    Response getById(SessionFactory factory,String id, String code, String encode);

    Response getTree(SessionFactory factory);

    Response getTreeLazy(SessionFactory factory, EquipmentQuery query);

    List<Equipment> getByViewType(SessionFactory factory, EquipmentQuery query);

    Response robotGetTreeLazy(SessionFactory factory, String parentId);

    Response getBasicParamsByTypeId(String typeId);

    Response getTechParamsByTypeId(String typeId);

    Response getParamById(SessionFactory factory, String paramId);

    File createMiniProgramQRCode(String eqId, String name, String envVersion);

    Map<String, List<EquipmentParams>> getParamsByTypeId(String typeId);

    Map<String, Map<String, EquipmentParams>> getGenericParams(SessionFactory factory, List<String> equipmentIds);

    Map<String, EquipmentParams> getGenericParam(SessionFactory factory, String equipmentId);

    List<EquipmentParams> getBatchBaseParams(SessionFactory factory, List<String> equipmentIds);

    Response moveNode(SessionFactory factory, String id, String parentId, Integer sort);

    Response batchMoveNode(SessionFactory factory, List<String> movelist, String targetId, Integer sort);

    Response drag(SessionFactory factory, String dragId, String targetId, String position);

    Response dragView(SessionFactory factory, String targetId);

    Response moveMoreNode(SessionFactory factory, List<String> ids, String parentId);

    /**
     * 根据位置id查询设备列表
     * @param factory
     * @param locationId
     * @return
     */
    List<Equipment> getEquipmentByLocation(SessionFactory factory,String locationId);

    /**
     * 根据父级id和设备id获取层级
     * @param factory
     * @param parentId
     * @param id
     * @return
     */
    Response<List> getFloor(SessionFactory factory,String parentId, String id);

    /**
     * 根据设备名称模糊查询
     * @param factory
     * @param query
     * @return
     */
    List<Equipment> queryList(SessionFactory factory, EquipmentQuery query);

    /**
     * 根据设备分类名称，模糊查询设备列表
     * @param factory
     * @param paramResult
     * @return
     */
    Response<List<Equipment>> getParamsByResult(SessionFactory factory, String paramResult);

    /**
     * 获取某个节点的所有父节点
     * @param factory
     * @param id
     * @return
     */
    Response<List<String>> getParentIds(SessionFactory factory, String id);

    /**
     * 获取同组织下，最左上的设备台账
     * @param factory
     * @param deptId 部门id
     * @param managerUnit 设备管理单位id
     * @return
     */
    Response getLeftUpperEquipmentByDeptId(SessionFactory factory, String deptId, String managerUnit);

    /**
     * 根据设备id查询查询其所有祖先节点，并组成一棵树
     * 包含当前节点
     */
    Equipment getUpTreeById(SessionFactory factory, String id);

    /**
     * 查询线路设备树，区别就是能查到经纬度和管理部门
     */
    List<LineEquipmentVo> getLineTreeLazy(SessionFactory factory, EquipmentQuery query);

    /**
     * 获取杆塔的部分参数，经度、纬度、管理部门
     */
    Map<String, Map<String, String>> getTowerParams(SessionFactory factory, List<String> equipmentIds);

    /**
     * 设备高级查询
     */
    PageInfo<EquipmentPo> advancedQueryEquipment(SessionFactory factory, PageQuery pageQuery, AdvancedQuery query);

    List<EquipmentExcel> export(SessionFactory factory, String equipmentId);

    Workbook getSheets(String id, List<Map<String, String>> errorMsglist, String groupId, SessionFactory factory);

    PageInfo<Equipment> queryEqlist(SessionFactory factory, PageQuery pageQuery, EqParamQuery query);
    Equipment getByERCode(SessionFactory factory, ERcodeQuery eRcodeQuery);

    List<EquipmentParams> searchParamsByName(SessionFactory factory,String paramName,String paramType);

    PageInfo<EquipmentPo> advancedEquipmentQuery(SessionFactory factory, PageQuery pageQuery, AdvancedQuery query);

    Response getEquipmentByParentId(SessionFactory factory, EquipmentQuery query);

}
